<?php
	header("content-type: text/xml");
	require_once '../includes/Config.inc.php';
	
	$cfg = Config::getInstance('..');
	$facebook = $cfg->getFacebook();
	
	$myUid = $facebook->require_login();
	$user = User::getUserFbID($myUid);

	// save the user facebook_session and facebook_secret to the database
	if(!empty($_POST['auth_token'])) {
		
		$hmm = $facebook->api_client->auth_getSession($_POST['auth_token'], true);
		
		$user->fb_session = $hmm['session_key'];
		$user->fb_secret = $hmm['secret'];
		$user->save();
		
		echo '<success>success</success>';
	}
	else
		echo '<error>No request submited</error>';
?>
